Cover hydrating mangled keys that all resolve to the object's own scope - #31
Merged
Merged
Conversation
The existing round trip hydrates a child class, so its array cast carries a parent-scoped key. That key alone can force an implementation to re-key the whole array to real property names, hiding whether the own-scope mangled keys would have been handled. Hydrate a class whose every mangled key resolves to itself, which is what (array) $obj yields for any class declaring only its own protected and private properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression insurance mirroring symfony/polyfill#643, which fixes a
deepclone_hydrate()bug in the polyfill: hydrating(array) $objfailed withError: Cannot access property starting with "\0"whenever every mangled key resolved to the object's own class scope, e.g.The extension is not affected: it resolves each key to its (scope, real name) individually, so there is no path that writes a mangled key verbatim. But the existing round trip here hydrates
Bar, whose array cast includes the parent-scoped"\0Foo\0priv", and that one key is enough to make an implementation re-key the whole array, masking whether the own-scope keys would have been handled on their own. The polyfill's mirror test had the same blind spot, which is why the bug shipped.This adds the isolated case: a class whose every mangled key resolves to itself, which is what
(array) $objyields for any class declaring only its own protected and private properties.Test-only, no behavior change. Verified green against PHP 8.4 and 8.5 (41/41 and 48/48).